import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayOrderVO, PayOrderForm, PayOrderQuery } from './types';

/**
 * 查询订单列表
 * @param query
 * @returns {*}
 */

export const listPayOrder = (query?: PayOrderQuery): AxiosPromise<PayOrderVO[]> => {
  return request({
    url: '/system/PayOrder/list',
    method: 'get',
    params: query
  });
};

// 查询订单列表统计
export const listCount = (query?: PayOrderQuery): AxiosPromise<PayOrderVO[]> => {
  return request({
    url: '/system/PayOrder/listCount',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单详细
 * @param orderId
 */
export const getPayOrder = (orderId: string | number): AxiosPromise<PayOrderVO> => {
  return request({
    url: '/system/PayOrder/' + orderId,
    method: 'get'
  });
};

/**
 * 新增订单
 * @param data
 */
export const addPayOrder = (data: PayOrderForm) => {
  return request({
    url: '/system/PayOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单
 * @param data
 */
export const updatePayOrder = (data: PayOrderForm) => {
  return request({
    url: '/system/PayOrder',
    method: 'put',
    data: data
  });
};

/**
 * 修改订单备注
 * @param data
 */
export const updatePayOrderRemark = (data: PayOrderForm) => {
  return request({
    url: '/system/PayOrder/remark',
    method: 'put',
    data: data
  });
};

/**
 * 修改订单状态
 */
export const updateOrderStatus = (data: any) => {
  return request({
    url: '/system/PayOrder/updateStatus',
    method: 'post',
    data
  });
};

/**
 * 删除订单
 * @param orderId
 */
export const delPayOrder = (orderId: string | number | Array<string | number>) => {
  return request({
    url: '/system/PayOrder/' + orderId,
    method: 'delete'
  });
};

/**
 * 同步ES数据
 */

export const syncESData = (orderId: string) => {
  return request({
    url: '/system/PayOrder/syncOrderToEs?orderId=' + orderId,
    method: 'post'
  });
};

export const trackPush = (trackList: any) => {
  return request({
    url: '/system/PayOrder/trackPush',
    method: 'post',
    data: {
      trackList
    }
  });
};

